package comCopier

import (
	"github.com/jinzhu/copier"
	"time"
)

func CopyWithOption(data1 any, data2 any) error {
	err := copier.CopyWithOption(data1, data2, copier.Option{IgnoreEmpty: true, Converters: []copier.TypeConverter{
		{
			SrcType: time.Time{},
			DstType: "",
			Fn: func(src interface{}) (interface{}, error) {
				srcTime, ok := src.(time.Time)
				if !ok {
					return "", nil
				}
				return srcTime.Format("2006-01-02 15:04:05"), nil
			},
		},
	}})
	return err
}
